-
Notifications
You must be signed in to change notification settings - Fork 18
Disable a few EC curves in computing shared secret #826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Disable a few EC curves in computing shared secret #826
Conversation
142a25e to
658cc4d
Compare
src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ibm/crypto/plus/provider/ECDHKeyAgreement.java
Outdated
Show resolved
Hide resolved
src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also various checkstyle failures:
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:12:1: Extra separation in import group before 'org.junit.jupiter.api.Assertions.assertTrue' [ImportOrder]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:14:1: Extra separation in import group before 'java.security.KeyPair' [ImportOrder]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:14:1: Wrong order for 'java.security.KeyPair' import. [ImportOrder]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:18:8: Unused import - java.security.SecureRandom. [UnusedImports]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:21:1: Extra separation in import group before 'javax.crypto.KeyAgreement' [ImportOrder]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:23:1: Extra separation in import group before 'org.junit.jupiter.api.BeforeAll' [ImportOrder]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:24:8: Unused import - org.junit.jupiter.api.Test. [UnusedImports]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:46:13: Unused local variable 'secretAlice'. [UnusedLocalVariable]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java:47:13: Unused local variable 'secretBob'. [UnusedLocalVariable]
Error: /home/runner/work/OpenJCEPlus/OpenJCEPlus/src/main/java/com/ibm/crypto/plus/provider/ECDHKeyAgreement.java:48:163: ',' is not followed by whitespace. [WhitespaceAfter]
Updated |
src/main/java/com/ibm/crypto/plus/provider/ECDHKeyAgreement.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ibm/crypto/plus/provider/ECDHKeyAgreement.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ibm/crypto/plus/provider/ECDHKeyAgreement.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ibm/crypto/plus/provider/ECDHKeyAgreement.java
Outdated
Show resolved
Hide resolved
f34f89b to
a1034a7
Compare
src/test/java/ibm/jceplus/junit/openjceplusfips/TestECDHKeyAgreementParamValidation.java
Show resolved
Hide resolved
a1034a7 to
d420201
Compare
d420201 to
a53dbf9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tests are currently failing with the latest code here for example:
[2025-10-29T13:44:41.910Z] java.lang.IllegalStateException: secp256k1 curve is not supported in FIPS for public key
[2025-10-29T13:44:41.910Z] at openjceplus/com.ibm.crypto.plus.provider.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:186)
[2025-10-29T13:44:41.910Z] at java.base/javax.crypto.KeyAgreement.generateSecret(KeyAgreement.java:613)
[2025-10-29T13:44:41.910Z] at openjceplus/ibm.jceplus.junit.base.BaseTestECDH.compute_ecdh_key(BaseTestECDH.java:268)
[2025-10-29T13:44:41.910Z] at openjceplus/ibm.jceplus.junit.base.BaseTestECDH.testECDH_ECSpec(BaseTestECDH.java:157)
[2025-10-29T13:44:41.910Z] at java.base/java.lang.reflect.Method.invoke(Method.java:571)
[2025-10-29T13:44:41.910Z] at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
[2025-10-29T13:44:41.910Z] at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
2025-10-29T13:44:42.457Z] [ERROR] Failures:
[2025-10-29T13:44:42.457Z] [ERROR] TestMultithreadFIPS.testMultithreadFIPS:178 Failed tests:
[2025-10-29T13:44:42.457Z] ibm.jceplus.junit.openjceplusfips.multithread.TestECDH
[2025-10-29T13:44:42.457Z] [ERROR] Errors:
[2025-10-29T13:44:42.457Z] [ERROR] TestECDH>BaseTestECDH.testECDH_ECSpec:157->BaseTestECDH.compute_ecdh_key:268 � IllegalState secp256k1 curve is not supported in FIPS for public key
[2025-10-29T13:44:42.457Z] [ERROR] TestECDH>BaseTestECDH.testECDH_secp192k1:114->BaseTestECDH.compute_ecdh_key:268 � IllegalState secp192k1 curve is not supported in FIPS for public key
[2025-10-29T13:44:42.457Z] [INFO]
[2025-10-29T13:44:42.457Z] [ERROR] Tests run: 2936, Failures: 1, Errors: 2, Skipped: 11
When I tested and printed the EC curves supported in FIPS 140-3, I got the following:
|
79e8788 to
0acfd74
Compare
0acfd74 to
50d2ecb
Compare
50d2ecb to
a9e6df6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
According to the policy, curve size less than 192 should not be allowed in computing shared secret in ECDH keyagreement in FIPS 140-3 mode. This PR proposes an option to enable/disable this behaviour. Signed-off-by: JinhangZhang <[email protected]>
a9e6df6 to
ad3d5fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
According to the policy, curve size less than 192 should not be allowed in computing shared secret in ECDH keyagreement in FIPS 140-3 mode.